<template>
	<div class="checkSelfDetail">

		<van-tabs v-model:active="tabState.active" animated sticky swipeable>
			<van-tab v-for="item in tabState.list" :title="item.title" :name="item.value" :key="item.value">
				<component
					:is="buildingDetail"
					v-if="+tabState.active === 1"
					:detail="houseData"
				/>
				<component
					:is="checkDataDetail"
					v-if="+tabState.active === 2"
					:detail="checkInfo"
				/>
			</van-tab>
		</van-tabs>
	</div>
</template>

<script setup>
import { onMounted, reactive, ref } from 'vue'
import buildingDetail from './components/buildingDetail'
import checkDataDetail from './components/checkDataDetail'
import { checkSelfInfo } from '@/service/api'
import { useRoute } from 'vue-router'

const route = useRoute()

const checkInfo = ref({})
const tabState = reactive({
	active: 1,
	list: [
		{ title: '房屋信息', value: 1 },
		{ title: '自查信息', value: 2 },
	]
})
const booleanKey = [
	'wdwhjgfjgqsyyrkrgbdj',
	'sstdsyyrkrclzx',
	'gryssdcsszblyyqksddp',
	'cjzwqtjyyt',
	'sfazfztsss',
]
const haveOrNotKey = [
	'ywgdlttxwd',
]
const haveEnum = {
	1: '有',
	0: '无'
}
const booleanEnum = {
	1: '是',
	0: '否'
}

const houseData = reactive({})

const getCheckInfo = async () => {
	try {
		const result = await checkSelfInfo({
			id: route.query.id,
		})
		if (result?.succ) {
			checkInfo.value = result?.data?.zmPcYhLog
			Object.keys(result?.data?.zmPcBaseLog).forEach(key => {
				houseData[key] = result?.data?.zmPcBaseLog[key]
			})
			booleanKey.map(item => {
				houseData[item] = booleanEnum[result?.data?.zmPcBaseLog?.[item]]
			})
			haveOrNotKey.map(item => {
				houseData[item] = haveEnum[result?.data?.zmPcBaseLog?.[item]]
			})
		}
	} catch (e) {
	}
}


onMounted(() => {
	getCheckInfo()
})
</script>

<style scoped lang="less">

</style>
